using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using InvestmentIntelligence.DbModel.CustomModels;

namespace InvestmentIntelligence.DbModel.Models
{
    [Table("Security", Schema = "MarketData")]
    public class Security
    {
        [Key]
        public int Id { get; set; }

        [MaxLength(20)]
        public string Isin { get; set; }
        
        [MaxLength(20)]
        public string Ric { get; set; }
        
        [MaxLength(20)]
        public string Mic { get; set; }
        
        [MaxLength(20)]
        public string Sedol { get; set; }
        
        [MaxLength(20)]
        public string CustomIdentificator { get; set; }

        public string Name { get; set; }
        public string LongName { get; set; }
        public int ClassId { get; set; }
        public int? CurrencyId { get; set; }
        public int EconomicSectorId { get; set; }
        public int CountryId { get; set; }
        public Nullable<int> ParentId { get; set; }
        
        [MaxLength(20)]
        public string ParentIdentify { get; set; }

        [MaxLength(20)]
        public string ParentIdentifyType { get; set; }
        public SecurityType? Type { get; set; }

        [ForeignKey("CountryId")]
        public virtual Country Country { get; set; }

        [ForeignKey("CurrencyId")]
        public virtual Currency Currency { get; set; }

        [ForeignKey("EconomicSectorId")]
        public virtual EconomicSector EconomicSector { get; set; }

        [ForeignKey("ClassId")]
        public virtual SecurityClass SecurityClass { get; set; }

        
        

        public string Ticker { get; set; }
        public string Cusip { get; set; }

        public override string ToString()
        {
            return string.Format("ID:{6} ISIN:{0} RIC:{1} MIC:{2} SEDOL: {3} CUST:{4} NAME:{5} CURRENCY:{7}", Isin, Ric, Mic, Sedol,
                CustomIdentificator, Name,Id,Currency.ISOCode);
        }
    }
}
